import { ORDER_GET_LIST, ORDER_CHANGE_FILTER } from '../action-types'
import { getOrderList } from '@app/api/order'
// import { store } from 'super-project'

export const getList = (filter) => (dispatch) => {

    getOrderList(filter)
        .then(res => dispatch({
            type: ORDER_GET_LIST,
            res
        }))
        .then(() => {
            window.scrollTo(0, 0)
        })
}

export const changeFilter = (filter) => ({
    type: ORDER_CHANGE_FILTER,
    filter
})

export const refresh = () => ({
    type: ORDER_CHANGE_FILTER,
    filter: {
        r: Math.random()
    }
})